// Copyright lowRISC contributors (OpenTitan project).
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0
//
// SECDED macros generated by
// util/design/secded_gen.py from util/design/data/secded_cfg.hjson

// This macro instantiates a secded decoder for the given _TYPE and _WIDTH.
// The instance will be named _INST, the data input connected to _ENC_DATA,
// and the data output, syndrome, and error connected to _DATA, _SYND, and
// _ERR respectively.
`define SECDED_INST_DEC(_TYPE, _WIDTH, _INST, _ENC_DATA, _DATA, _SYND, _ERR) \
  case (_TYPE)                                                               \
    prim_secded_pkg::SecdedHsiao: begin : gen_dec_hsiao                      \
      case (_WIDTH)                                                          \
        29: begin : gen_dec_hsiao_29                                         \
          prim_secded_36_29_dec _INST(                                       \
            .data_i(_ENC_DATA),                                              \
            .data_o(_DATA),                                                  \
            .syndrome_o(_SYND),                                              \
            .err_o(_ERR));                                                   \
        end                                                                  \
        32: begin : gen_dec_hsiao_32                                         \
          prim_secded_39_32_dec _INST(                                       \
            .data_i(_ENC_DATA),                                              \
            .data_o(_DATA),                                                  \
            .syndrome_o(_SYND),                                              \
            .err_o(_ERR));                                                   \
        end                                                                  \
        48: begin : gen_dec_hsiao_48                                         \
          prim_secded_55_48_dec _INST(                                       \
            .data_i(_ENC_DATA),                                              \
            .data_o(_DATA),                                                  \
            .syndrome_o(_SYND),                                              \
            .err_o(_ERR));                                                   \
        end                                                                  \
        64: begin : gen_dec_hsiao_64                                         \
          prim_secded_72_64_dec _INST(                                       \
            .data_i(_ENC_DATA),                                              \
            .data_o(_DATA),                                                  \
            .syndrome_o(_SYND),                                              \
            .err_o(_ERR));                                                   \
        end                                                                  \
        default: begin : gen_dec_hsiao_default                               \
        end                                                                  \
      endcase                                                                \
    end                                                                      \
  endcase

// This macro instantiates a secded encoder for the given _TYPE and _WIDTH.
// The instance is named _INST, the data input connects to _DATA, and the
// data output connects to _ENC_DATA.
`define SECDED_INST_ENC(_TYPE, _WIDTH, _INST, _DATA, _ENC_DATA) \
  case (_TYPE)                                                  \
    prim_secded_pkg::SecdedHsiao: begin : gen_enc_hsiao         \
      case (_WIDTH)                                             \
        29: begin : gen_enc_hsiao_29                            \
          prim_secded_36_29_enc _INST(                          \
            .data_i(_DATA),                                     \
            .data_o(_ENC_DATA));                                \
        end                                                     \
        32: begin : gen_enc_hsiao_32                            \
          prim_secded_39_32_enc _INST(                          \
            .data_i(_DATA),                                     \
            .data_o(_ENC_DATA));                                \
        end                                                     \
        48: begin : gen_enc_hsiao_48                            \
          prim_secded_55_48_enc _INST(                          \
            .data_i(_DATA),                                     \
            .data_o(_ENC_DATA));                                \
        end                                                     \
        64: begin : gen_enc_hsiao_64                            \
          prim_secded_72_64_enc _INST(                          \
            .data_i(_DATA),                                     \
            .data_o(_ENC_DATA));                                \
        end                                                     \
        default: begin : gen_enc_hsiao_default                  \
        end                                                     \
      endcase                                                   \
    end                                                         \
  endcase
